Trò chơi bắn đạn đơn giản sử dụng Unity
13.466 lượt xem;
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class GameCtrl : MonoBehaviour {
6
7 public static GameCtrl instance;
8
9 private void Awake()
10 {
11 if (instance == null)
12 {
13 instance = this;
14 }
15
16 }
17
18 /// <summary>
19 /// Called when the player bullet hits the enemy
20 /// </summary>
21 /// <param name="enemy"></param>
22 public void BulletHitEnemy(Transform enemy)
23 {
24 // destroy the enemy
25 Destroy(enemy.gameObject);
26 }
27 }
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class GameCtrl : MonoBehaviour {
6
7 public static GameCtrl instance;
8
9 private void Awake()
10 {
11 if (instance == null)
12 {
13 instance = this;
14 }
15
16 }
17
18 /// <summary>
19 /// Called when the player bullet hits the enemy
20 /// </summary>
21 /// <param name="enemy"></param>
22 public void BulletHitEnemy(Transform enemy)
23 {
24 // destroy the enemy
25 Destroy(enemy.gameObject);
26 }
27 }
Called when the player bullet hits the enemy
destroy the enemy